package com.tbit.main.controller;

import cn.hutool.core.date.DateUtil;
import com.tbit.common.entity.pojo.dto.ReturnBikeMsgLogDTO;
import com.tbit.common.entity.pojo.vo.ParkPointCoreDataVO;
import com.tbit.common.entity.pojo.vo.ReturnBikeMsgLogVO;
import com.tbit.common.entity.view.Result;
import com.tbit.manager.api.ParkPointOAServiceApi;
import com.tbit.common.entity.pojo.vo.HeatMapStatVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 运营分析-站点分析
 *
 * @author <a href="mailto:chen.wutian@tbit.com.cn">BUGTian</a>
 * @since 2025/2/27
 */
@Validated
@RestController
@RequestMapping("/operationsAnalysis/parkPoint")
public class ParkPointOAController {

    @Autowired
    private ParkPointOAServiceApi parkPointOAServiceApi;

    /**
     * 获取站点分析核心数据
     *
     * @param accountId 区域id
     * @param startTime 开始时间
     * @param endTime   结束时间
     */
    @GetMapping("/getCoreData")
    public Result<ParkPointCoreDataVO> getCoreData(@NotNull Integer accountId, @NotNull String startTime, @NotNull String endTime) {
        return Result.success(parkPointOAServiceApi.getCoreData(accountId, DateUtil.parseDateTime(startTime),
                DateUtil.parseDateTime(endTime)));
    }

    /**
     * 获取申诉还车点
     *
     */
    @GetMapping("/getApplyReturnBikePoint")
    public Result<List<ReturnBikeMsgLogVO>> getApplyReturnBikePoint(ReturnBikeMsgLogDTO returnBikeMsgLogDTO) {
        return Result.success(parkPointOAServiceApi.getApplyReturnBikePoint(returnBikeMsgLogDTO));
    }

    /**
     * 获取站点分析核心数据
     *
     * @param accountId 区域id
     * @param startTime 开始时间 字符串(yyyy-MM-dd HH:mm:ss)
     * @param endTime   结束时间 字符串(yyyy-MM-dd HH:mm:ss)
     * @param type      类型 0: 借车 1: 还车
     * @param mapType   地图类型 1: 百度 2: 高德
     * @param regionIds 分区id 英文逗号拼接
     */
    @GetMapping("/statHeatMap")
    public Result<List<HeatMapStatVO>> statHeatMap(@NotNull Integer accountId, @NotNull String startTime, @NotNull String endTime,
                                                   Integer type, @RequestParam(defaultValue = "2") Integer mapType,
                                                   @RequestParam(required = false) String regionIds) {
        return Result.success(parkPointOAServiceApi.statHeatMap(accountId, DateUtil.parse(startTime).getTime(),
                DateUtil.parse(endTime).getTime(), type, mapType, regionIds));
    }

}